package com.huangliusong.desigin.pattern.creational.prototype.clone;

import com.huangliusong.desigin.pattern.creational.singleton.HungrySingleton;
import com.huangliusong.desigin.principle.singleresponsbility.Method;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

/**
 * @author huangliusong
 * @since 2018/10/11
 * {@link Pig}
 */
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Date date=new Date(0L);
        Pig pig1=new Pig("佩琦",date);
        Pig pig2= (Pig) pig1.clone();


        System.out.println(pig1);
        System.out.println(pig2);

        pig1.getBirthday().setTime(6666);


        System.out.println(pig1);
        System.out.println(pig2);


//        HungrySingleton hungrySingleton=HungrySingleton.getInstance();
//        java.lang.reflect.Method method=hungrySingleton.getClass().getDeclaredMethod("clone");
//        method.setAccessible(true);
//        HungrySingleton cloneHungrySingleton= (HungrySingleton) method.invoke(hungrySingleton);
//
//        System.out.println(hungrySingleton);
//        System.out.println(cloneHungrySingleton);


    }
}
